﻿@model Web.Models.MovieViewModel
           

@if (ViewBag.FormMode == Web.Helper.Mode.Create)
{
    using (Html.BeginForm("MovieAdd", "Workers", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        <div class="form" style="width: 600px">

            <div class="formtitle">Tworzenie nowego filmu:</div>
            
            <div class="input">
			    <div class="inputtext">Tytuł:</div>
			    <div class="inputcontent">
				    @Html.TextBoxFor(mk => mk.Movie.MovieTitle)
                    <div class="inputcontenterror">
                        @Html.ValidationMessageFor(model => model.Movie.MovieTitle)
                        <div class="inputcontenterror">
                            @Html.ValidationMessageFor(model => model.Movie.MovieTitle)
                        </div>
                    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Reżyser:</div>
			    <div class="inputcontent">
				    @Html.TextBoxFor(mk => mk.Movie.MovieDirector)
                    <div class="inputcontenterror">
                        @Html.ValidationMessageFor(model => model.Movie.MovieDirector)
                        <div class="inputcontenterror">
                            @Html.ValidationMessageFor(model => model.Movie.MovieDirector)
                        </div>
                    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Wydawca:</div>
			    <div class="inputcontent">
				    @Html.TextBoxFor(mk => mk.Movie.MoviePublisher)
                    <div class="inputcontenterror">
                        @Html.ValidationMessageFor(model => model.Movie.MoviePublisher)
                    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Data wydania:</div>
			    <div class="inputcontent">
				    @Html.TextBoxFor(mk => mk.Movie.MovieIssueDate, new { @id = "date1" })
                    <div class="inputcontenterror">
                        @Html.ValidationMessageFor(mk => mk.Movie.MovieIssueDate)
                    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Czas trwania:</div>
			    <div class="inputcontent">
				    @Html.TextBoxFor(mk => mk.Movie.MovieDuration)
                    *długość filmu wyrażona w minutach
                    <div class="inputcontenterror">
                        @Html.ValidationMessageFor(model => model.Movie.MovieDuration)
                    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Kategorie:</div>
			    <div class="inputcontent">
				    <div class="inputcheckbox">
                    @Html.CheckBoxListFor(x => x.PostedKinds.KindsIDs,
														  x => x.AvailableKinds,
														  x => x.MovieKindID,
														  x => x.MovieKindName,
														  x => x.SelectedKinds)
                    </div>
			    </div>
		    </div>
            
            <div class="input">
			    <div class="inputtext">Okładka:</div>
			    <div class="inputcontent">
				    
                    @if (Model != null && Model.Movie != null && Model.Movie.Files != null && Model.Movie.Files.FileUrl != null)
                    {
                        <img class="cover" src='@String.Format("http://{0}/Uploads/{1}", Request.Url.Host, Model.Movie.Files.FileUrl)' alt="cover" />
                    }
                    else
                    {
                        <img class="cover" src='@String.Format("http://{0}/Uploads/movie_unknown.jpg", Request.Url.Host)' alt="cover" />
                    }
                    
                    <input type="file" name="imageFile" />

			    </div>
		    </div>

            <div class="buttons">
				<input class="orangebutton" type="submit" value="Dodaj film" />
			</div>
    </div>
    }
}
else if (ViewBag.FormMode == Web.Helper.Mode.Edit)
{
    using (Html.BeginForm("MovieEdit", "Workers", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
    <div class="form" style="width: 600px">
        
            @Html.HiddenFor(x => x.Movie.MovieGuid)

            <div class="formtitle">Edycja filmu:</div>
            
            <div class="input">
			    <div class="inputtext">Tytuł:</div>
			    <div class="inputcontent">
				    @Html.TextBoxFor(mk => mk.Movie.MovieTitle)
                    <div class="inputcontenterror">
                        @Html.ValidationMessageFor(model => model.Movie.MovieTitle)
                        <div class="inputcontenterror">
                            @Html.ValidationMessageFor(model => model.Movie.MovieTitle)
                        </div>
                    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Reżyser:</div>
			    <div class="inputcontent">
				    @Html.TextBoxFor(mk => mk.Movie.MovieDirector)
                    <div class="inputcontenterror">
                        @Html.ValidationMessageFor(model => model.Movie.MovieDirector)
                        <div class="inputcontenterror">
                            @Html.ValidationMessageFor(model => model.Movie.MovieDirector)
                        </div>
                    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Wydawca:</div>
			    <div class="inputcontent">
				    @Html.TextBoxFor(mk => mk.Movie.MoviePublisher)
                    <div class="inputcontenterror">
                        @Html.ValidationMessageFor(model => model.Movie.MoviePublisher)
                        <div class="inputcontenterror">
                            @Html.ValidationMessageFor(model => model.Movie.MoviePublisher)
                        </div>
                    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Data wydania:</div>
			    <div class="inputcontent">
				    @Html.TextBoxFor(mk => mk.Movie.MovieIssueDate)
                    <div class="inputcontenterror">
                        @Html.ValidationMessageFor(mk => mk.Movie.MovieIssueDate)
                    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Czas trwania:</div>
			    <div class="inputcontent">
				    @Html.TextBoxFor(mk => mk.Movie.MovieDuration)
                    *długość filmu wyrażona w minutach
                    <div class="inputcontenterror">
                        @Html.ValidationMessageFor(model => model.Movie.MovieDuration)
                    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Kategorie:</div>
			    <div class="inputcontent">
				    <div class="inputcheckbox">
                    @Html.CheckBoxListFor(x => x.PostedKinds.KindsIDs,
														  x => x.AvailableKinds,
														  x => x.MovieKindID,
														  x => x.MovieKindName,
														  x => x.SelectedKinds)
                    </div>
			    </div>
		    </div>
            
            <div class="input">
			    <div class="inputtext">Okładka:</div>
			    <div class="inputcontent">
				    
                   @if (Model != null && Model.Movie != null && Model.Movie.Files != null && Model.Movie.Files.FileUrl != null)
                    {
                        <img class="cover" src='@String.Format("http://{0}/Uploads/{1}", Request.Url.Host, Model.Movie.Files.FileUrl)' alt="cover" />
                    }
                    else
                    {
                        <img class="cover" src='@String.Format("http://{0}/Uploads/movie_unknown.jpg", Request.Url.Host)' alt="cover" />
                    }
                    
                    <input type="file" name="imageFile" />

			    </div>
		    </div>

            <div class="buttons">
				<input class="orangebutton" type="submit" value="Zapisz zmiany" />
			</div>
    </div>
    }
}
else
{
     <div class="form" style="width: 600px">
        
            @Html.HiddenFor(x => x.Movie.MovieGuid)

            <div class="formtitle">Informacje o filmie:</div>
            
            <div class="input">
			    <div class="inputtext">Tytuł:</div>
			    <div class="inputcontent">
				    @Html.DisplayFor(mk => mk.Movie.MovieTitle)
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Reżyser:</div>
			    <div class="inputcontent">
				    <div class="inputcontent">
				    @Html.DisplayFor(mk => mk.Movie.MovieDirector)
			    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Wydawca:</div>
			    <div class="inputcontent">
				    <div class="inputcontent">
				    @Html.DisplayFor(mk => mk.Movie.MoviePublisher)
			    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Data wydania:</div>
			    <div class="inputcontent">
				    <div class="inputcontent">
				    @Html.DisplayFor(mk => mk.Movie.MovieIssueDate)
			    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Czas trwania:</div>
			    <div class="inputcontent">
				   <div class="inputcontent">
				    @Html.DisplayFor(mk => mk.Movie.MovieDuration)
			    </div>
			    </div>
		    </div>

            <div class="input">
			    <div class="inputtext">Kategorie:</div>
			    <div class="inputcontent">
				    
                    @if (Model != null && Model.Movie != null && Model.Movie.MovieMovieKinds != null)
                    {
                        foreach (MovieMovieKinds kind in Model.Movie.MovieMovieKinds)
                        {
                            <p>
                                @kind.MovieKinds.MovieKindName
                            </p>
                        }
                    }
                    else
                    {
                         <p>Brak</p>
                    }

			    </div>
		    </div>
            
            <div class="input">
			    <div class="inputtext">Okładka:</div>
			    <div class="inputcontent">
				    
                    @if (Model != null && Model.Movie != null && Model.Movie.Files != null && Model.Movie.Files.FileUrl != null)
                    {
                        <img class="cover" src='@String.Format("http://{0}/Uploads/{1}", Request.Url.Host, Model.Movie.Files.FileUrl)' alt="cover" />
                    }
                    else
                    {
                        <img class="cover" src='@String.Format("http://{0}/Uploads/movie_unknown.jpg", Request.Url.Host)' alt="cover" />
                    }
                    
			    </div>
		    </div>
    </div>
    
}